package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.SpecialWorkTicketApproval;
import com.ruoyi.yanjing.service.ISpecialWorkTicketApprovalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特种作业票审批信息Controller
 * 
 * @author whz
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/yanjing/approval")
public class SpecialWorkTicketApprovalController extends BaseController
{
    @Autowired
    private ISpecialWorkTicketApprovalService specialWorkTicketApprovalService;

    /**
     * 查询特种作业票审批信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:approval:list')")
    @GetMapping("/list")
    public TableDataInfo list(SpecialWorkTicketApproval specialWorkTicketApproval)
    {
        startPage();
        List<SpecialWorkTicketApproval> list = specialWorkTicketApprovalService.selectSpecialWorkTicketApprovalList(specialWorkTicketApproval);
        return getDataTable(list);
    }

    /**
     * 导出特种作业票审批信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:approval:export')")
    @Log(title = "特种作业票审批信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpecialWorkTicketApproval specialWorkTicketApproval)
    {
        List<SpecialWorkTicketApproval> list = specialWorkTicketApprovalService.selectSpecialWorkTicketApprovalList(specialWorkTicketApproval);
        ExcelUtil<SpecialWorkTicketApproval> util = new ExcelUtil<SpecialWorkTicketApproval>(SpecialWorkTicketApproval.class);
        util.exportExcel(response, list, "特种作业票审批信息数据");
    }

    /**
     * 获取特种作业票审批信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:approval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(specialWorkTicketApprovalService.selectSpecialWorkTicketApprovalById(id));
    }

    /**
     * 新增特种作业票审批信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:approval:add')")
    @Log(title = "特种作业票审批信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpecialWorkTicketApproval specialWorkTicketApproval)
    {
        return toAjax(specialWorkTicketApprovalService.insertSpecialWorkTicketApproval(specialWorkTicketApproval));
    }

    /**
     * 修改特种作业票审批信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:approval:edit')")
    @Log(title = "特种作业票审批信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpecialWorkTicketApproval specialWorkTicketApproval)
    {
        return toAjax(specialWorkTicketApprovalService.updateSpecialWorkTicketApproval(specialWorkTicketApproval));
    }

    /**
     * 删除特种作业票审批信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:approval:remove')")
    @Log(title = "特种作业票审批信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(specialWorkTicketApprovalService.deleteSpecialWorkTicketApprovalByIds(ids));
    }
}
